﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MenusHunter.Core.Helper
{
    public class PhotosHelper
    {
        public static List<Photo> GetListPhotoRetaurant(int resId)
        {
            using (var db = new MenusHunterDataContext() )
            {
                return (from p in db.Photos where p.RestaurantId == resId select p).ToList();
            }
        }

        public static bool NewPhoto(Photo p)
        {
            using (var db = new MenusHunterDataContext() )
            {
                db.Photos.InsertOnSubmit(p);

                return p.Id>0;
            }
        }

        public static bool DeletePhoto(Photo p)
        {
            using (var db = new MenusHunterDataContext())
            {
                db.Photos.DeleteOnSubmit(p);
                db.SubmitChanges();
                return true;
            }
        }

        public static bool DeletePhotoByRestaurant(Photo p)
        {
            using (var db = new MenusHunterDataContext())
            {
                db.Photos.DeleteOnSubmit(p);
                db.SubmitChanges();
                return true;
            }
        }

    }
}
